#include "DropletRandomWalk/DropletRandomWalk.h"

DropletRandomWalk::DropletRandomWalk(ObjectPhysicsData *objPhysics) 
	: IDroplet(objPhysics) 
{ return; }

DropletRandomWalk::~DropletRandomWalk() { return; }

void DropletRandomWalk::DropletInit()
{
	ResetAllSystems();
	SeedRandom(static_cast<int32_t>(GetDropletID()));

	SetRGB(0, 0, 255);
	colorSet = 0;
}

void DropletRandomWalk::DropletMainLoop()
{
	// Set a random color
	if(IsMoving() == 0)	// Not moving
	{
		if(colorSet == 0)
		{
			SetRGB(0, 0, 255);
			colorSet = 1;
		}

		
		if(GetRandom() < 10)
		{
			uint8_t r = GetRandom();
			uint8_t g = GetRandom();
			uint8_t b = GetRandom();
			SetRGB(r, g, b);
			Move(2, (r % 6) + 1);

			colorSet = 0;	 // Reset color after stop.
		}
	}
}